package org.fuyd.designpattern.proxy;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Test {
  public static void main(String[] args) throws IOException {
    String src =
        "package org.fuyd.designpattern.proxy;" +

          "public class TankTimeProxy implements Moveable {" +
  
          "Moveable m;" +
  
          "public TankTimeProxy(Moveable m) {" + "super();" + "this.m = m;" + "}" +
  
          "public void move() {" + 
            "long start = System.currentTimeMillis();" + "m.move();" + 
            "long end = System.currentTimeMillis();" + 
            "System.out.println(\"运行了：\" + (end - start) + \"毫秒\");" + "}" + 
          "}";
    System.out.println(System.getProperty("user.dir"));
    String fileName = System.getProperty("user.dir")+"/src/main/java/org/fuyd/designpattern/proxy/TankTimeProxy.java";
    System.out.println(fileName);
    File file = new File(fileName);
    FileWriter writer = new FileWriter(file);
    writer.write(src);
    writer.flush();
    writer.close();
  }
}
